/*
 * @description: 
 * @Author: lal
 * @Date: 2021-04-26 15:00:35
 * @LastEditors: lal
 * @LastEditTime: 2021-04-26 15:14:22
 */
/*
 * @lc app=leetcode.cn id=206 lang=javascript
 *
 * [206] 反转链表
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function(head) {
    if(!head||!head.next) return head;
    let prev=null,cur=head
    while(cur !== null){
        let next =cur.next
        cur.next =prev
        prev=cur
        cur=next
    }
    return prev

};
// @lc code=end

